#!/usr/bin/env bash

RUNDIR=$(dirname $0)

if [[ -d ~/.zshrc ]];then
    source ~/.zshrc
fi

server='root@erp-dev.jiutiandata.com'

echo "sync server -> \`${server}\`"

app_name='pd'
cd ${RUNDIR}/ && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $app_name
# upx put ${RUNDIR}/${app_name}

scp -P 2100 ${RUNDIR}/${app_name} ${server}:/tmp/${app_name}
ssh -p 2100 ${server} "source ~/.zshrc && bash /var/golang/install.sh $app_name"


md5 ${RUNDIR}/${app_name}
rm ${RUNDIR}/${app_name}
